package com.suxg.hbase.mapper;

import java.util.Map;

import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.springframework.util.ObjectUtils;

import com.suxg.hbase.api.RowMapper;
import com.suxg.hbase.model.F;

public class FMapper implements RowMapper<F> {
	private static byte[] COLUMN_FAMILY = "F".getBytes();
	private static byte[] CID = "cid".getBytes();
	private static byte[] SDF = "sdf".getBytes();

	@Override
	public F mapRow(Result result, int rowNum,Map map) {
		String cid = "";
		String sdf = "";
		byte[] bcid = result.getValue(COLUMN_FAMILY, CID);
		byte[] bsdf = result.getValue(COLUMN_FAMILY, SDF);
		if (!ObjectUtils.isEmpty(bcid)) {
			cid = Bytes.toString(result.getValue(COLUMN_FAMILY, CID));
		}
		if (!ObjectUtils.isEmpty(bsdf)) {
			sdf = Bytes.toString(result.getValue(COLUMN_FAMILY, SDF));
		}
		F f = new F();
		f.setCid(cid);
		f.setSdf(sdf);
		return f;
	}

}
